package com.ruoyi.location.service.impl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.ruoyi.shelf.domain.Shelf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.location.mapper.LocationMapper;
import com.ruoyi.location.domain.Location;
import com.ruoyi.location.service.ILocationService;

/**
 * 货位管理Service业务层处理
 * 
 * @author lh
 * @date 2024-10-28
 */
@Service
public class LocationServiceImpl implements ILocationService 
{
    @Autowired
    private LocationMapper locationMapper;

    /**
     * 查询货位管理
     * 
     * @param id 货位管理主键
     * @return 货位管理
     */
    @Override
    public Location selectLocationById(Long id)
    {
        return locationMapper.selectLocationById(id);
    }

    /**
     * 查询货位管理列表
     * 
     * @param location 货位管理
     * @return 货位管理
     */
    @Override
    public List<Location> selectLocationList(Location location)
    {
        return locationMapper.selectLocationList(location);
    }

    /**
     * 新增货位管理
     * 
     * @param location 货位管理
     * @return 结果
     */
    @Override
    public int insertLocation(Location location)
    {
        return locationMapper.insertLocation(location);
    }

    /**
     * 修改货位管理
     * 
     * @param location 货位管理
     * @return 结果
     */
    @Override
    public int updateLocation(Location location)
    {
        return locationMapper.updateLocation(location);
    }

    /**
     * 批量删除货位管理
     * 
     * @param ids 需要删除的货位管理主键
     * @return 结果
     */
    @Override
    public int deleteLocationByIds(Long[] ids)
    {
        return locationMapper.deleteLocationByIds(ids);
    }

    /**
     * 删除货位管理信息
     * 
     * @param id 货位管理主键
     * @return 结果
     */
    @Override
    public int deleteLocationById(Long id)
    {
        return locationMapper.deleteLocationById(id);
    }

    /**
     * 获取该货架下的所有货位
     */
    @Override
    public List<Location> selectByPid(Long id, String locationNo, Integer status) {
        return locationMapper.selectByPid(id,locationNo,status);
    }

    @Override
    public int insertAllLocation(ArrayList<Location> list) {

        return locationMapper.addAll(list);
    }

    /**
     * 查询没有占用的货位
     *
     * @param location 货位管理
     * @return 货位管理集合
     */
    @Override
    public List<Location> selectLocation(Location location) {
        return locationMapper.selectLocation(location);
    }

    @Override
    public List<Location> select(Location location) {
        return locationMapper.select(location);
    }
}
